1. Technical Field
This invention generally relates to object oriented programming and more specifically relates to a mechanism and method for storing and retrieving elements of collections in an object oriented environment.
2. Background Art
The development of the EDVAC computer system of 1948 is often cited as the beginning of the computer era. Since that time, computer systems have evolved into extremely sophisticated devices, and computer systems may be found in many different settings. Computer systems typically include a combination of hardware, such as semiconductors and circuit boards, and software, also known as computer programs. As advances in semiconductor processing and computer architecture push the performance of the computer hardware higher, more sophisticated computer software has evolved to take advantage of the higher performance of the hardware, resulting in computer systems today that are much more powerful than just a few years ago.
Computer systems typically include operating system software that controls the basic function of the computer, and one or more software application programs that run under the control of the operating system to perform desired tasks. For example, a typical IBM Personal Computer may run the OS/2 operating system, and under the control of the OS/2 operating system, a user may execute an application program, such as a word processor. As the capabilities of computer systems have increased, the application software programs designed for high performance computer systems have become extremely powerful. Additionally, software development costs have continued to rise because more powerful and complex programs take more time, and hence more money, to produce.
One way in which the performance of application software programs has been improved while the associated development costs have been reduced is by using object oriented programming concepts. The goal of using object oriented programming is to create small, reusable sections of program code known as xe2x80x9cobjectsxe2x80x9d that can be quickly and easily combined and re-used to create new programs. This is similar to the idea of using the same set of building blocks again and again to create many different structures. The modular and re-usable aspects of objects will typically speed development of new programs, thereby reducing the costs associated with the development cycle. In addition, by creating and re-using a comprehensive set of well-tested objects, a more stable, uniform, and consistent approach to developing new computer programs can be achieved.
A central concept in object oriented programming is the xe2x80x9cclass.xe2x80x9d A class is a template that defines a type of object. A class outlines or describes the characteristics or makeup of objects that belong to that class. By defining a class, objects can be created that belong to the class without having to rewrite the entire definition for each new object. This feature of object oriented programming promotes the reusability of existing object definitions and promotes more efficient use of program code.
Many software applications need to operate on data that already exists, and need to store data for later use by another software application. A database is generally used to store persistent data, that is, data that survives beyond the life of a software process that may create, use, or modify the data. Databases are known in the art as persistent storage mechanisms (or simply, persistent stores). Often, data in an object oriented computer system needs to be stored in a xe2x80x9ccollectionxe2x80x9d, which is a grouping of objects that have one or more common characteristics. A collection is typically defined by an object that stores references to objects that are elements of the collection, and by object methods that allow adding an element, removing an element, and replacing an element in the collection (referred to collectively herein as xe2x80x9cmaintaining elementsxe2x80x9d on the collection). One known way to provide a collection defines one or more xe2x80x9ckeysxe2x80x9d that are used to classify data within the collection, and provides intelligence regarding how that elements in the collection may be maintained within the collection itself. However, this approach requires a programmer to custom-define the constraints and the operations for maintaining the collection for each collection in the system. In addition, known containers that are used to store collections may use character strings as a key, but do not have the ability to use object pointers as a key. Thus, a programmer must typically provide a set of limited keys that have unique string identifiers that allows them to be used as keys. These limitations create a significant amount of work for the programmer that needs to provide the capability of maintaining information in a collection using keys in an object oriented program. Without a mechanism for allowing a programmer to flexibly define keys for a collection and constraints on maintenance of elements within the collection, the computer industry will continue to suffer from excessive development costs for object oriented applications that are custom-programmed to support particular key and maintenance constraints with very little reusability of the code.
In an object oriented computer system, an object oriented mechanism and method defines a common interface to maintain elements on a collection while providing the capability of using virtually any suitable object as a key to the collection. A programmer defines an interface on a collection that includes suitable object methods for adding, removing, and replacing elements of the collection. The constraints that determine whether elements may be added, removed, or replaced is encapsulated in a policy that is defined by the programmer. The programmer identifies one or more keys, which may include any suitable object in the object oriented system. A maintainer class provides a client interface for maintaining elements on the collection according to the defined policy and according to the keys defined by the programmer. The present invention recognizes the common characteristics that exist in maintaining elements on a keyed collection, and provide predetermined classes and class relationships that provide support for maintaining any collection using any key that a programmer may define.
The foregoing and other features and advantages of the invention will be apparent from the following more particular description of preferred embodiments of the invention, as illustrated in the accompanying drawings.